/********************************************************RUN COMPARE_EP_STOIBER DO FILE FIRST BEFORE RUNNING THIS CODEIF YOU DO NOT RUN FIX-IGC FIRST, THE DATA USED IN THISFILE COULD BE WRONGJBS- 12/01/05 Examine patterns of missingness in Amsterdam data.Runs poisson model and probit model to determine sources of missingnessRev: JBS 02/19/2006Rev 04/18/2006*********************************************************/clearversion 8.2set mem 50m*change working dircd "/Users/jslapin/Documents/papers and diss/IO Replication Materials/"*Use data with missing valuesuse "temp/ams_jbs_temp.dta", clear* report number missing by actorcount if com ==.count if ep==.count if b==.count if dk==.count if d==.count if gr==.count if e==.count if f==.count if irl==.count if i==.count if lux==.count if nl==.count if a==.count if p==.count if sf==.count if s==.count if uk==.* Here I run the main analysis assuming listwise deletion* Transform data so sq always equals 0* This code transforms each member state position if sq~=0replace com= abs(com-sq) if sq~=0     replace ep= abs(ep-sq) if sq~=0replace b= abs(b-sq) if sq~=0replace dk= abs(dk-sq) if sq~=0replace d= abs(d-sq) if sq~=0replace gr= abs(gr-sq) if sq~=0replace e= abs(e-sq) if sq~=0replace f= abs(f-sq) if sq~=0replace irl= abs(irl-sq) if sq~=0replace i= abs(i-sq) if sq~=0replace lux= abs(lux-sq) if sq~=0replace nl= abs(nl-sq) if sq~=0replace a= abs(a-sq) if sq~=0replace p= abs(p-sq) if sq~=0replace sf= abs(sf-sq) if sq~=0replace s= abs(s-sq) if sq~=0replace uk= abs(uk-sq) if sq~=0replace am= abs(am-sq) if sq~=0replace sq=0 if sq~=0*calculate number of actors on SQgen sqdumb=1 if b==sqreplace sqdumb=0 if sqdumb==.gen sqdumdk=1 if dk==sqreplace sqdumdk=0 if sqdumdk==.gen sqdumd=1 if d==sqreplace sqdumd=0 if sqdumd==.gen sqdumgr=1 if gr==sqreplace sqdumgr=0 if sqdumgr==.gen sqdume=1 if e==sqreplace sqdume=0 if sqdume==.gen sqdumf=1 if f==sqreplace sqdumf=0 if sqdumf==.gen sqdumirl=1 if irl==sqreplace sqdumirl=0 if sqdumirl==.gen sqdumi=1 if i==sqreplace sqdumi=0 if sqdumi==.gen sqdumlux=1 if lux==sqreplace sqdumlux=0 if sqdumlux==.gen sqdumnl=1 if nl==sqreplace sqdumnl=0 if sqdumnl==.gen sqduma=1 if a==sqreplace sqduma=0 if sqduma==.gen sqdump=1 if p==sqreplace sqdump=0 if sqdump==.gen sqdumsf=1 if sf==sqreplace sqdumsf=0 if sqdumsf==.gen sqdums=1 if s==sqreplace sqdums=0 if sqdums==.gen sqdumuk=1 if uk==sqreplace sqdumuk=0 if sqdumuk==.gen numsq=sqdumb+sqdumdk+sqdumd+sqdumgr+sqdume/**/+sqdumf+sqdumirl+sqdumi+sqdumlux+sqdumnl+sqduma+/**/sqdump+sqdumsf+sqdums+sqdumuk* Create number missing variable to count number member states missing by issue egen nummissing=rmiss(b dk d gr e f irl i lux nl a p sf s uk)* create variable to count total missingegen nummissingtot=sum(nummissing)* CALCULATE BDM VAR AS A SHARE OF COUNCIL VOTES - THESE RESULTS ARE NOT IN THE PAPER!!!!* This only calculates the variable for issues with no missingness* Assumes listwise deletion*calculate share of council votesgen vsb=5/87gen vsdk=3/87gen vsd=10/87gen vsgr=5/87gen vse=8/87gen vsf=10/87gen vsirl=3/87gen vsi=10/87gen vslux=2/87gen vsnl=5/87gen vsa=4/87gen vsp=5/87gen vssf=3/87gen vss=4/87gen vsuk=10/87gen utilitydraftb=vsb*(-(b-1)^2-(-(b-sq)^2))gen utilitydraftdk=vsdk*(-((dk-1)^2)-(-(dk-sq)^2))gen utilitydraftd=vsd*(-(d-1)^2-(-(d-sq)^2))gen utilitydraftgr=vsgr*(-(gr-1)^2-(-(gr-sq)^2))gen utilitydrafte=vse*(-(e-1)^2-(-(e-sq)^2))gen utilitydraftf=vsf*(-(f-1)^2-(-(f-sq)^2))gen utilitydraftirl=vsirl*(-(irl-1)^2-(-(irl-sq)^2))gen utilitydrafti=vsi*(-(i-1)^2-(-(i-sq)^2))gen utilitydraftlux=vslux*(-(lux-1)^2-(-(lux-sq)^2))gen utilitydraftnl=vsnl*(-(nl-1)^2-(-(nl-sq)^2))gen utilitydrafta=vsa*(-(a-1)^2-(-(a-sq)^2))gen utilitydraftp=vsp*(-(p-1)^2-(-(p-sq)^2))gen utilitydraftsf=vssf*(-(sf-1)^2-(-(sf-sq)^2))gen utilitydrafts=vss*(-(s-1)^2-(-(s-sq)^2))gen utilitydraftuk=vsuk*(-(uk-1)^2-(-(uk-sq)^2))gen BDMpred= utilitydraftb+utilitydraftdk+utilitydraftd+utilitydraftgr+/**/utilitydrafte+utilitydraftf+utilitydraftirl+utilitydrafti+utilitydraftlux+/**/utilitydraftnl+utilitydrafta+utilitydraftp+utilitydraftsf+utilitydrafts+utilitydraftuk*calculate simple weighted average variable assuming listwise deletiongen waveb=vsb*bgen wavedk=vsdk*dkgen waved=vsd*dgen wavegr=vsgr*grgen wavee=vse*egen wavef=vsf*fgen waveirl=vsirl*irlgen wavei=vsi*igen wavelux=vslux*luxgen wavenl=vsnl*nlgen wavea=vsa*agen wavep=vsp*pgen wavesf=vssf*sfgen waves=vss*sgen waveuk=vsuk*ukgen wave=waveb+wavedk+waved+wavegr+wavee+wavef+waveirl /**/+wavei+wavelux+wavenl+wavea+wavep+wavesf+waves+waveukglm am numsq nummissing, family(bin) link(probit)glm am nummissing, family(bin) link(probit)glm am numsq BDMpred, family(bin) link(probit) vceglm am numsq wave, family(bin) link(probit) * Even using listwise deletion, numsq is still a better predictor of issue inclusion*Here I simply provide summaries of the dependent variable to show that high missingness* is clearly related to the dependent variable  *count non missing obs per issueegen nomissing=robs(b dk d gr e f irl i lux nl a p sf s uk)sum am if nomissing==15sum am if nomissing<15* Now I begin to perform analysis to predict the pattern of missingness* rename vars for reshapingrename com poscomrename ep poseprename b posbrename dk posdkrename d posdrename gr posgrrename e poserename f posfrename irl posirlrename i posirename lux posluxrename nl posnlrename a posarename p posprename sf possfrename s possrename uk posuk* include member state population variable - taken from EuroStatgen popb= 10170226gen popdk= 5275121gen popd= 82012162 gen popgr=10744649gen pope=39525438 gen popf=58116018 gen popirl=3654955gen popi=56879278 gen poplux=416850gen popnl=15567107 gen popa=7964966gen popp=10072542 gen popsf=5132320 gen pops=8844499 gen popuk=58905050 reshape long pos vs pop, i(issue) j(memstate) stringkeep issue memstate kateg ia pos sq am vs popgen misspos=1 if pos==.replace misspos=0 if misspos==.gen multipargov=1 if memstate=="b"|memstate=="dk"|memstate=="d"|memstate=="f"|memstate=="i"|memstate=="irl"|memstate=="nl"|memstate=="a"|memstate=="sf"|memstate=="lux"replace multipargov=0 if multipargov==.*rescale population and generate log of populationreplace pop=pop/100000gen lnpop=ln(pop)*generate mean position of actors for reported preferencesbys memstate: egen avepos=mean(pos)save "temp/temp1.dta", replace* Generate average government range across all issues for all member states using * Marks and Steenbergen Expert 1999 Expert Survey data - contact me for information about how these are created use  "MSexpert99.dta"  collapse govposmaxEP govposmaxfiscal govposmaxemploy govposmaxcohesion /**/ govposmaxenviron govposmaxasylum govposmaxforeign govposminEP govposminfiscal /**/govposminemploy govposmincohesion govposminenviron govposminasylum govposminforeign/**/ govposaveEP govposavefiscal govposaveemploy govposavecohesion govposaveenviron /**/govposaveasylum govposaveforeign govposwaveEP govposwavefiscal govposwaveemploy /**/govposwavecohesion govposwaveenviron govposwaveasylum govposwaveforeign, by(country)reshape long govposmax govposmin govposave govposwave, i(country) j(MSissuearea) stringgen govrange=govposmax-govposmingen memstate="b" if country==1replace memstate ="dk" if country==2replace memstate="d" if country==3replace memstate="gr" if country==4replace memstate="e" if country==5replace memstate="f" if country==6replace memstate="irl" if country==7replace memstate="i" if country==8replace memstate="nl" if country==10replace memstate="uk" if country==11replace memstate="p" if country==12replace memstate="a" if country==13replace memstate="sf" if country==14replace memstate="s" if country==16sort memstatecollapse govrange, by(memstate)save "temp/temp2.dta", replaceuse "temp/temp1.dta", clearsort memstatejoinby memstate using "temp/temp2", unmatched(both)* collapse data to run poisson model * generate number missing var by memstatebys memstate: egen nummiss=sum(misspos)collapse nummiss lnpop avepos multipargov govrange, by(memstate)* THIS IS THE MODEL FOUND IN PAPER TABLES TABLES 2 AND A1poisson nummiss lnpop avepos multipargovestsimp poisson nummiss lnpop avepos multipargov setx lnpop mean avepos mean multipargov minsimqi, fd(ev) changex(multipargov 0 1)simqi, fd(ev) changex(avepos min max)simqi, fd(ev) changex(lnpop min max)drop b1 b2 b3 b4estsimp poisson nummiss lnpop avepos multipargov if memstate~="lux"setx lnpop mean avepos mean multipargov minsimqi, fd(ev) changex(multipargov 0 1)simqi, fd(ev) changex(avepos min max)simqi, fd(ev) changex(lnpop 3.599 max)